<!DOCTYPE html>
<html>
	<head lang="en">
		<meta charset="UTF-8">
		<title>操作当当购物车页面</title>
		<link type="text/css" rel="stylesheet" href="cartStyle.css" />
		<script type="text/javascript">
			function adddog() {
				var a = parseInt(document.getElementById("dog").value) + 1;
				document.getElementById("dog").value = a;
				var p = parseFloat(document.getElementById("dogp").value) * a;
				document.getElementById("dogp0").value = p.toFixed(2);
			}

			function subtractiondog() {
				var s = parseInt(document.getElementById("dog").value) - 1;
				if (s < 0) {
					alert("购买数量不能小于0!请重新输入!")
					retun;
				}
				document.getElementById("dog").value = s;
				var p = parseFloat(document.getElementById("dogp").value) * s;
				document.getElementById("dogp0").value = p.toFixed(2);
			}
			function add() {
				var a = parseInt(document.getElementById("haze").value) + 1;
				document.getElementById("haze").value = a;
				var p = parseFloat(document.getElementById("hazep").value) * a;
				document.getElementById("hazep0").value = p.toFixed(2);
			}
			
			function subtraction() {
				var s = parseInt(document.getElementById("haze").value) - 1;
				if (s < 0) {
					alert("购买数量不能小于0!请重新输入!")
					retun;
				}
				document.getElementById("haze").value = s;
				var p = parseFloat(document.getElementById("hazep").value) * s;
				document.getElementById("hazep0").value = p.toFixed(2);
			}
			function total(){
				var d=parseFloat(document.getElementById("dogp0").value);
				var h=parseFloat(document.getElementById("hazep0").value);
				document.getElementById("to").innerHTML=(d+h).toFixed(2);
			}
			function collection(){
				
				alert("收藏成功！")
			}
			function del(){
				if(confirm("是否确定删除此项?")){
					alert("删除成功！")
				}
			}
			function gb(){
				if(confirm("是否确定的关闭购物车？")){
					close();
					alert("购物车已关闭！")
				}else{
					alert("您已取消关闭！")
				}
			}
		</script>
	</head>
	<body>

		<div class="content">
			<div class="logo">
				<img src="../imgs/dd_logo.jpg"><span onclick="gb();">关闭</span>
			</div>
			<div class="cartList" id="cartList">
				<ul>
					<li>商品图片</li>
					<li>商品信息</li>
					<li>单价</li>
					<li>数量</li>
					<li>总价</li>
					<li>操作</li>
				</ul>
				<ul>
					<li><img src="../imgs/dog.jpg"></li>
					<li>我和狗狗活下来了</li>
					<li>¥<input type="text" name="price" id="dogp" value="21.90"></li>
					<li><input type="button" name="minus" value="-" onclick="subtractiondog()"><input type="text"
							name="amount" id="dog" value="0"><input type="button" name="plus" value="+" onclick="adddog()">
					</li>
					<li id="price0">¥<input type="text" name="price" id="dogp0" value="0"></li>
					<li>
						<p onclick="collection();">移入收藏</p>
						<p onclick="del();">删除</p>
					</li>
				</ul>
				<ul>
					<li><img src="../imgs/mai.jpg"></li>
					<li>灰霾来了怎么办</li>
					<li>¥<input type="text" name="price" id="hazep" value="24.00"></li>
					<li><input type="button" name="minus" value="-" onclick="subtraction()"><input type="text" name="amount" id="haze"
							value="0"><input type="button" name="plus" value="+" onclick="add()"></li>
					<li id="price1">¥<input type="text" name="price" id="hazep0" value="0"></li>
					<li>
						<p onclick="collection();">移入收藏</p>
						<p onclick="del();">删除</p>
					</li>
				</ul>
				<ol>
					<li id="totalPrice">商品总计：<span id="to"></span></li>
					<li><span onclick="total()">结 算</span></li>
				</ol>
			</div>
		</div>
	</body>
</html>
